package com.sgb.kjwl.view.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import com.sgb.kjwl.databinding.MapInfoWindow6Binding;

import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.manage.TheEnterpriseOfEntity;
import com.swgk.core.util.DateUtils;

public class MapInfoWindow6 extends LinearLayout {

    protected Context mContext;
    protected MapInfoWindow6Binding viewBinding;
    private TheEnterpriseOfEntity entity;

    public MapInfoWindow6(Context context) {
        this(context, null);
    }

    public MapInfoWindow6(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public MapInfoWindow6(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public MapInfoWindow6(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
        initView();
    }

    private void initView() {
        viewBinding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.map_info_window6, this, true);
    }

    public void setData(TheEnterpriseOfEntity entity) {
        this.entity = entity;
        viewBinding.titleView.setText(entity.getSupplierName());
        if (entity.getAuthTime() != 0) {
            viewBinding.tvAuthYear.setText(DateUtils.timestampTo13Date3NoHours(entity.getAuthTime()));
        } else {
            viewBinding.tvAuthYear.setText("暂无数据");
        }
        viewBinding.tvAddress.setText(entity.getAdress());
        viewBinding.tvDistance.setText(entity.getDistance() + "km");
        if (entity.getMainBusiness() != null && !entity.getMainBusiness().equals("")) {
            viewBinding.companyView.setText(entity.getMainBusiness());
        } else {
            viewBinding.companyView.setText("暂无数据");
        }
    }

    public TheEnterpriseOfEntity getData() {
        return entity;
    }
}
